Skip to content

Fix translated rich text attribute hydration and storage in admin#2445

Merged
alecritson merged 4 commits intolunarphp:1.xfrom
tazzytazzy:fix/translated-richtext-attribute-data
Apr 13, 2026
Merged

Fix translated rich text attribute hydration and storage in admin#2445
alecritson merged 4 commits intolunarphp:1.xfrom
tazzytazzy:fix/translated-richtext-attribute-data

Conversation

@tazzytazzy
Copy link
Copy Markdown
Contributor

Problem Statement

Translated rich text product attributes were not being normalized correctly when Lunar built the Filament form state.

That caused two related problems:

  • On page load, locale keys like description.en / description.es were missing from Livewire state, which triggered entangle errors and left rich text fields effectively unbound.
  • On save, translated rich text values could still contain nested TipTap document arrays instead of plain strings, which broke when Lunar tried to store them as TranslatedText field values.

This mainly affected multiline translated fields such as descriptions and similar rich text attributes in the product editor.

What Changed

  • Updated packages/admin/src/Support/Forms/AttributeData.php to recursively unwrap field type values before they are passed into form state.
  • Added translated-text-specific normalization so admin forms always receive a complete locale map for configured languages, even when a value is empty.
  • Added save-side normalization for translated rich text fields so locale values are converted to storage-safe strings before Lunar instantiates the underlying TranslatedText field type.
    -Converted any per-locale TipTap document arrays to HTML during dehydration, which matches what Lunar core expects to persist.

Result

Translated rich text attributes now:

  • hydrate with stable per-locale form state on initial page load
  • avoid Livewire entangle errors for missing locale keys
  • save successfully without passing raw rich editor document arrays into Lunar core

Scope

This patch only addresses the main hydration/persistence issue in AttributeData.

The separate TranslatedTextSynth changes are intentionally excluded from this PR.

Code Generation Source
I highly supervised Codex 5.4 on Extra reasoning settings. I have also personally tested the results within the Lunar admin panel, and the patch is working as expected. During testing, Codex pointed out other issues that I will submit changes requests for, namely the TranslatedText and TranslatedTextSynth for testing.

Mitch Schwenk added 2 commits April 11, 2026 14:59
The names would be listed twice for both the attribute groups and the
attribute names within a group. This fixes that. Includes testing
for this fix too.
@alecritson alecritson self-requested a review April 13, 2026 14:21
@alecritson alecritson merged commit 445221c into lunarphp:1.x Apr 13, 2026
44 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Apr 13, 2026
@tazzytazzy tazzytazzy deleted the fix/translated-richtext-attribute-data branch April 13, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants